<!--评论添加-->
<?php
$conn=new mysqli("localhost","root","123456","htmlkeshe");
$conn->query("set names utf8");

$newsId = $_GET['newsId'];
session_start();
$result = $conn->query("select * from news where newsId='".$newsId."'");
$info = mysqli_fetch_assoc($result);
$newsName = $info['title'];
$userName = $_SESSION['name'];
$userId = $_SESSION['id'];

$content = $_GET['content'];
$time = date("Y-m-d H:i:s");
$sql="insert into comment (newsId,newsName,userId,userName,content,time) VALUES(".$newsId.",'".$newsName."',".$_SESSION["id"].",'".$_SESSION["name"]."','".$content."','".$time."');";
$result=$conn->query($sql);
//评论加热度
$sql="select * from news where newsId=".$_GET['newsId'].";";
$result=$conn->query($sql);
$info = $result->fetch_assoc();
$heat = $info['heat']+9;
$sql = "update news set heat =".$heat." where newsId=".$_GET['newsId'].";";
//echo $sql;
$conn->query($sql);
//echo $sql;
$conn->close();
